/**
 * 
 */
package com.gmail.blackdog1987.carcare.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.gmail.blackdog1987.carcare.BaseActivity;
import com.gmail.blackdog1987.carcare.R;
import com.gmail.blackdog1987.carcare.network.response.IResponse;
import com.gmail.blackdog1987.carcare.network.response.handler.IResponseHandler;
import com.gmail.blackdog1987.carcare.network.response.handler.OnResponseListener;
import com.umeng.analytics.MobclickAgent;
import com.umeng.update.UmengUpdateAgent;
import com.umeng.update.UmengUpdateListener;
import com.umeng.update.UpdateResponse;
import com.umeng.update.UpdateStatus;

/**
 * @author wdy
 * 
 */
public class LaunchActivity extends BaseActivity implements OnClickListener,
		OnResponseListener {
	private Context mContext;

	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_launch);
		mContext = this;

		initViews();
		initData(savedInstanceState);
		reg();
		update();
	}

	private void update() {
		UmengUpdateAgent.setUpdateAutoPopup(false);
		UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
			@Override
			public void onUpdateReturned(int updateStatus,
					UpdateResponse updateInfo) {
				switch (updateStatus) {
				case UpdateStatus.Yes: // has update
					UmengUpdateAgent.showUpdateDialog(mContext, updateInfo);
					break;
				case UpdateStatus.No: // has no update
					// Toast.makeText(mContext, "没有更新",
					// Toast.LENGTH_SHORT).show();
					break;
				case UpdateStatus.NoneWifi: // none wifi
					// Toast.makeText(mContext, "没有wifi连接， 只在wifi下更新",
					// Toast.LENGTH_SHORT).show();
					break;
				case UpdateStatus.Timeout: // time out
					// Toast.makeText(mContext, "超时",
					// Toast.LENGTH_SHORT).show();
					break;
				}
			}
		});
		UmengUpdateAgent.update(this);
	}

	public void initViews() {

	}

	public void reg() {
	}

	public void initData(Bundle savedInstanceState) {
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
		default:
			break;
		}

	}

	@Override
	public void onResponse(IResponseHandler classz) {

		IResponse response = classz.getResponse();
	}

	@Override
	public void onError(IResponseHandler classz) {

	}

	/**
	 * umeng
	 */
	public void onResume() {
		super.onResume();
		MobclickAgent.onResume(this); // 统计时长
	}

	/**
	 * umeng
	 */
	public void onPause() {
		super.onPause();
		MobclickAgent.onPause(this);
	}
}
